package pe.gob.foncodes.ssa.bs.common.util;

import java.util.HashMap;
import java.util.Map;

/**
 *
 */
public final class JRExporterStrategyFactory {

    private Map<String, JRExporterStrategy> pool;
    private static JRExporterStrategyFactory instance;
    public static final String exporterFormat = "pdf;xls";

    private JRExporterStrategyFactory() {
        pool = new HashMap<String, JRExporterStrategy>();
        pool.put("pdf", new PDFExporter());
        pool.put("xls", new ExcelExporter());
    }

    public static JRExporterStrategyFactory getInstance() {
        if (instance == null) {
            instance = new JRExporterStrategyFactory();
        }
        return instance;
    }

    public synchronized JRExporterStrategy get(String format) {
        JRExporterStrategy exporter = pool.get(format);
        if (exporter == null) {
            exporter = pool.get("pdf");
        }
        return exporter;
    }

    public static String[] getExporterFormats() {
        return exporterFormat.split(";");
    }
}